gallery.Rmdlibrary(dplyr)
library(echarts4r.assets)
# download
flights <- jsonlite::fromJSON("https://ecomfe.github.io/echarts-examples/public/data-gl/asset/data/flights.json")
# airports
airports <- as.data.frame(flights$airports)
names(airports) <- flights$airportsFields
airports <- airports %>%
select(name, longitude, latitude) %>%
tibble::rownames_to_column("ID") %>%
mutate(ID = as.integer(paste0(ID)))
# routes
routes <- as.data.frame(flights$routes)
names(routes) <- c("ID", "from", "to")
# airlines
airlines <- as.data.frame(flights$airlines) %>%
tibble::rownames_to_column("ID") %>%
mutate(ID = as.integer(paste(ID))) %>%
select(ID, airline = V1, country = V2)
# bind
data <- routes %>%
inner_join(airports, by = c("from" = "ID")) %>%
inner_join(airports, by = c("to" = "ID"), suffix = c(".start", ".end")) %>%
inner_join(airlines, by = "ID") %>%
select(airline, longitude.start, latitude.start, longitude.end, latitude.end)
# initialise plot
data %>%
group_by(airline) %>%
e_charts() %>%
e_globe(
base_texture = ea_asset("world dark"),
environment = ea_asset("starfield"),
displacementScale = 0.1,
displacementQuality = "high",
shading = "realistic",
realisticMaterial = list(
roughness = .2,
metalness = 0
),
postEffect = list(
enable = TRUE,
depthOfField = list(
enable = FALSE
)
),
temporalSuperSampling = list(
enable = TRUE
),
light = list(
ambient = list(
intensity = 1
),
main = list(
intensity = .1,
shadow = FALSE
)
),
viewControl = list(autoRotate = FALSE)
) %>%
e_legend(
selectedMode = "single",
left = "left",
textStyle = list(color = "#fff"),
orient = "vertical"
) %>%
e_lines_3d(
longitude.start, latitude.start, longitude.end, latitude.end,
coord_system = "globe",
effect = list(
show = TRUE,
trailWidth = 2,
trailLength = 0.15,
trailOpacity = 1,
trailColor = 'rgb(30, 30, 60)'
),
lineStyle = list(opacity = 0.1, widh = 0.5, color = 'rgb(50, 50, 150)')
)data <- jsonlite::fromJSON("http://gallery.echartsjs.com/asset/get/s/data-1491887968120-rJODPy9ae.json")
data <- as.data.frame(data) %>%
magrittr::set_names(c("x", "y", "z")) %>%
filter(z > 0) %>%
mutate(z = sqrt(z))
data %>%
e_charts(x) %>%
e_globe(
base_texture = ea_asset("world topo"),
environment = ea_asset("starfield"),
displacementScale = 0.04,
shading = "realistic",
realisticMaterial = list(
roughness = .9
),
postEffect = list(
enable = TRUE
)
) %>%
e_legend(
show = FALSE
) %>%
e_scatter_3d(
y, z,
coord_system = "globe",
blendMode = "lighter",
symbolSize = 2
) %>%
e_visual_map(
show = FALSE,
min = 0, max = 60,
inRange = list(1, 10)
)This is a temporary implementation of the timeline component, it will, eventually, be properly incorporated into the package.
aggregate <- OrchardSprays %>%
group_by(treatment, colpos) %>%
summarise(
decrease = sum(decrease)
) %>%
group_by(treatment)
OrchardSprays %>%
group_by(treatment) %>%
e_timeline(rowpos) %>%
e_timeline_serie(decrease) %>%
e_data(aggregate, colpos) %>%
e_timeline_serie(decrease, type = "pie", base_opts = list(
center = list("75%", "35%"),
radius = "20%"
))